#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "user_config.h"
#include "framework.h"
#include "service.h"




	

void on_detect_voltage()
{
	static unsigned int c = 0;
	
	c++;
	printf("ok %d\r\n", c);
	
	soft_timer_start(SOFT_TIMER_DETECT_VOLTAGE, DETECT_VOLTAGE_INTERVAL);	
}



void on_key_test_short_press()
{
	printf("on key test short press\r\n");
	LED_TEST_TOGGLE();
}


void on_key_test_long_press()
{
	printf("on key test long press\r\n");
}






void service_init()
{
	event_register(EVENT_KEY_TEST_SHORT_PRESS, on_key_test_short_press);
	event_register(EVENT_KEY_TEST_LONG_PRESS, on_key_test_long_press);
	event_register(EVENT_DETECT_VOLTAGE, on_detect_voltage);

	
	soft_timer_manual_register(SOFT_TIMER_DETECT_VOLTAGE, EVENT_DETECT_VOLTAGE);
	soft_timer_start(SOFT_TIMER_DETECT_VOLTAGE, DETECT_VOLTAGE_INTERVAL);
}

